package com.jinke.api.modules.app.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum ChannelStatus {

    OFF(0, "禁用"),
    ON(1, "启用"),
    ;
    @EnumValue
    @JsonValue
    private final int value;
    private final String desc;
    ChannelStatus(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static ChannelStatus defaultEnum(int value) {
        for (ChannelStatus type : ChannelStatus.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("No element matches " + value);
    }
}